//
//  main.m
//  02_HomeWork
//
//  Created by dllo on 16/7/5.
//  Copyright © 2016年 LST. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
   
    /** 初始化(init) */
    NSString *str0 = [[NSString alloc] init];
    str0 = @"老王";
    
    /** 便利构造器(string) */
    NSString *str1 = [NSString stringWithFormat:@"爬墙"];
    
    /** 获取字符串长度(length) */
    NSLog(@"%ld", str1.length);
    
    /** 获取字符串中字符(character) */
    unichar character = [str1 characterAtIndex:0];
    NSLog(@"character:%c", character);
    
    /** 字符串是否相等(equal) */
    NSString *str2 = [NSString stringWithFormat:@"0.0"];
    BOOL isEqual = [str1 isEqualToString:str2];
    NSLog(@"equal:%d", isEqual);
    
    /** 获取子串(sub) */
    NSString *sub = [str1 substringWithRange:NSMakeRange(0, 1)];
    NSLog(@"subString:%@", sub);
    
    /** 拼接字符串(append) */
    NSString *append = [str1 stringByAppendingString:str2];
    NSLog(@"append:%@", append);
    
    /** 替换字符串(replace) */
    NSString *replace = [str1 stringByReplacingOccurrencesOfString:@"lol" withString:@"什么鬼"];
    NSLog(@"replace:%@", replace);
    
    /** 字符串对象转化为int类型(int) */
    int strInt = str1.intValue;
    NSLog(@"intValue:%d", strInt);
    
    /** 字符串对象转化为其他数据类型, 例如double, float, BOOL等. */
    double strDouble = str1.doubleValue;
    float strFloat = str1.floatValue;
    NSLog(@"double:%f", strDouble);
    NSLog(@"float:%f", strFloat);
    
    /** 字符串全部大写(uppercase) */
    NSString *upper = str1.uppercaseString;
    NSLog(@"uppercase:%@", upper);
    
    /** 字符串全部小写(lowercase) */
    NSString *lower = str1.lowercaseString;
    NSLog(@"lower:%@", lower);
    
    /** 字符串首字母大写(capitalized) */
    NSString *capitalized = str1.capitalizedString;
    NSLog(@"capitalized:%@", capitalized);
    
    /** 是否以指定字符串为前缀(prefix) */
    BOOL hasPrefix = [str1 hasPrefix:@"H"];
    NSLog(@"prefix:%d", hasPrefix);
    
    /** 是否以指定字符串为后缀(suffix) */
    BOOL hasSuffix = [str1 hasSuffix:@"o"];
    NSLog(@"suffix:%d", hasSuffix);
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}
